import { createRouter, type RouteRecordRaw, createWebHistory } from "vue-router"

const routes: Array<RouteRecordRaw> = [
  {
    name: "login",
    path: "/login",
    component: () => import("@/view/login/index.vue"),
    meta: {
      id: 1,
      img: new URL("../../public/img/login.png", import.meta.url).href,
      back: false,
      title: "欢迎回来",
      description: "登录，留下更多精彩",
      input: [
        { title: "邮箱地址", placeholder: "请输入邮箱", type: "email" },
        { title: "密码", placeholder: "请输入密码", type: "password" }
      ],
      check1: true,
      check2: false,
      check3: false,
      email: false,
      button: "登录"
    }
  },
  {
    name: "register",
    path: "/register",
    component: () => import("@/view/register/index.vue"),
    meta: {
      id: 2,
      img: new URL("../../public/img/register.png", import.meta.url).href,
      back: false,
      title: "创建新用户",
      description: "注册，分享更多精彩",
      input: [
        { title: "用户名", placeholder: "请输入用户名", type: "text" },
        { title: "邮箱", placeholder: "请输入邮箱", type: "email" },
        { title: "密码", placeholder: "请输入密码", type: "password" },
        { title: "重复密码", placeholder: "请再次输入密码", type: "password" }
      ],
      check1: false,
      check2: true,
      check3: false,
      email: true,
      button: "注册"
    }
  },
  {
    name: "forgotpwd",
    path: "/forgotpwd",
    component: () => import("@/view/forgotpwd/index.vue"),
    meta: {
      id: 3,
      img: new URL("../../public/img/forgotpwd.png", import.meta.url).href,
      back: true,
      title: "忘记密码",
      description: "验证您的邮箱以重新设置密码",
      input: [
        { title: "邮箱地址", placeholder: "请输入邮箱", type: "email" }
      ],
      check1: false,
      check2: false,
      check3: false,
      email: false,
      button: "发送验证码"
    }
  },
  {
    name: "otp",
    path: "/otp",
    component: () => import("@/view/otp/index.vue"),
    meta: {
      id: 4,
      img: new URL("../../public/img/forgotpwd.png", import.meta.url).href,
      back: true,
      title: "验证码",
      description: "输入我们发给您的邮箱验证码以继续重置密码",
      check1: false,
      check2: false,
      check3: true,
      email: false,
      button: "验证"
    }
  },
  {
    name: "resetpwd",
    path: "/resetpwd",
    component: () => import("@/view/resetpwd/index.vue"),
    meta: {
      id: 5,
      img: new URL("../../public/img/login.png", import.meta.url).href,
      back: true,
      title: "重置密码",
      description: "请重置您的密码",
      input: [
        { title: "新密码", placeholder: "请输入您的新密码", type: "password" },
        { title: "重复新密码", placeholder: "请再次输入您的新密码", type: "password" }
      ],
      check1: false,
      check2: false,
      check3: false,
      email: false,
      button: "重置密码"
    }
  },
  {
    name: 'home',
    path: "/home",
    component: () => import("@/view/Home/index.vue")
  },
  {
    name: 'shop',
    path: "/shop",
    component: () => import("@/view/shop/index.vue")
  },
  {
    name: 'detail',
    path: "/detail/:id",
    component: () => import("@/view/shopDetail/index.vue")
  },
  {
    name: 'checkout',
    path: "/checkout",
    component: () => import("@/view/checkout/index.vue")
  },
  {
    name: "pay",
    path: "/pay",
    component: () => import("@/view/pay/index.vue"),
    children: [
      {
        name: "pay_address",
        path: "address",
        component: () => import("@/view/pay/address/index.vue"),
        meta: {
          title: "收货地址",
          line1: false, // 步骤条 第一条虚线
          line2: false, // 步骤条 第二条虚线
          cube2: false, // 步骤条 支付方式步骤
          cube3: false, // 步骤条 订单详情步骤
          btn: false, // 右边方框下面的按钮
          text: ""
        }
      },
      {
        name: "pay_method",
        path: "method",
        component: () => import("@/view/pay/method/index.vue"),
        meta: {
          title: "支付方式",
          line1: true,
          line2: false,
          cube2: true,
          cube3: false,
          btn: false,
          text: ""
        }
      },
      {
        name: "pay_review",
        path: "review",
        component: () => import("@/view/pay/review/index.vue"),
        meta: {
          title: "支付确认",
          line1: true,
          line2: true,
          cube2: true,
          cube3: true,
          btn: true,
          text: "确认支付"
        }
      }
    ]
  },
  {
    name: 'profile',
    path: '/profile',
    component: () => import("@/view/profile/index.vue"),
    children: [
      {
        name: 'profile_my',
        path: 'my',
        component: () => import("@/view/profile/my/index.vue")
      },
      {
        name: 'profile_order',
        path: 'order',
        component: () => import("@/view/profile/order/index.tsx")
      },
      {
        name: 'profile_love',
        path: 'love',
        component: () => import("@/view/profile/love/index.tsx")
      },
      {
        name: 'profile_password',
        path: 'password',
        component: () => import('@/view/profile/password/index.tsx')
      },
      {
        name: 'profile_notify',
        path: 'notify',
        component: () => import("@/view/profile/notify/index.vue")
      },
      {
        name: 'profile_setting',
        path: 'setting',
        component: () => import("@/view/profile/setting/index.vue")
      }
    ]
  },
  {
    path: "/",
    redirect: "/home",
  }
]

export default createRouter({
  history: createWebHistory(),
  routes,
  scrollBehavior (to, from, savedPosition) {
    // 滚动到顶部
    return { top: 0 }
  }
})